const path = require('path');
const {config} = require('vuepress-theme-hope');

module.exports = config({
    title: '楚果数据',
    description: 'Just do it!',
    head: [// 会加入<head>中
        ['link', {rel: 'icon', href: '/logo.ico'}],// 指定浏览器Tab图标
        ['link', {rel: 'shortcut icon', href: '/favicon.ico'}],// 指定浏览器Tab图标
        ['link', {rel: 'stylesheet', href: 'https://at.alicdn.com/t/c/font_1320506_x6qg3n2aln.css'}],
        ['script', {}, `
            var _hmt = _hmt || [];
            (function() {
              var hm = document.createElement("script");
              hm.src = "https://hm.baidu.com/hm.js?d1bf315daa170b109d46ec4104837458";
              var s = document.getElementsByTagName("script")[0]; 
              s.parentNode.insertBefore(hm, s);
            })();
        `],
        /*['link', { rel: 'manifest', href: '/manifest.json' }],//PWA
        ['link', { rel: 'apple-touch-icon', href: '/logo.png' }]// 指定safari浏览器保存书签至桌面图标*/
    ],
    alias: {
        '@': path.resolve(__dirname, './public'),
    },
    serviceWorker: true,
    base: '/docs/',// 部署时指定存放的项目的地址
    markdown: {
        lineNumbers: true, // 代码块行号显示
        extractHeaders: ['h1', 'h2', 'h3', 'h4']
    },

    themeConfig: {
        iconPrefix: 'fas fa-fw ',
        hostname: 'http://doc.chuguotech.com',
        logo: '/logo.png',// 主页显示图标
        // anchorDisplay: true,
        git: {
            contributor: false,
        },
        footer: {
            display: true,
            content: '版权 © 上海楚果信息技术有限公司. 保留一切版权.'
        },
        manifest: {
            name: 'IBI文档-楚果数据 让数据分析变得简单 普及敏捷BI'
        },
        algolia: {
            apiKey: 'ece1fd7e9819dc599e59c6749cd246d1',
            indexName: 'chuguotech',
            appId: 'SH0SDDZN6F',
        },
        mdEnhance: {
            enableAll: true,
            align: true,
            // 启用下角标功能
            sub: true,
            // 启用上角标
            sup: true,
            flowchart: true,
            footnote: true,
        },
        wordPerminute: 100,
        pwa: {
            favicon: '/favicon.ico',
        },
        nav: [
            {text: '首页', link: 'https://www.chuguotech.com', icon: 'fas fa-home'},// 首页地址不想指定的话就不用改，默认指向docs下面的README.md
            {text: '介绍', link: '/zh-cn/intro/preface', icon: 'fas fa-book-reader'},
            {text: '操作指南', link: '/zh-cn/manual/3-foldersystem', icon: 'fas fa-book'},
            {
                text: '发布日志', icon: 'fa fa-clipboard-list', items: [
                    {
                        text: '摘要',
                        items: [
                            {text: '2024', link: '/zh-cn/releases/digest/2024.md'},
                            {text: '2023', link: '/zh-cn/releases/digest/2023.md'},
                            {text: '2022', link: '/zh-cn/releases/digest/2022.md'},
                            {text: '2021', link: '/zh-cn/releases/digest/2021.md'},
                            {text: '2020', link: '/zh-cn/releases/digest/2020.md'},
                            {text: '2019', link: '/zh-cn/releases/digest/2019.md'},
                            {text: '2018', link: '/zh-cn/releases/digest/2018.md'},
                            {text: '16,17', link: '/zh-cn/releases/digest/2017-2016.md'},
                        ],
                    },
                    // NavbarGroup
                    {
                        text: '图文介绍',
                        items: [
                            {text: 'v1.14', link: '/zh-cn/releases/v1.14/'},
                            {text: 'v1.13', link: '/zh-cn/releases/v1.13/'},
                            {text: 'v1.12', link: '/zh-cn/releases/v1.12/'},
                            {text: 'v1.11', link: '/zh-cn/releases/v1.11/'},
                            {text: 'v1.10', link: '/zh-cn/releases/v1.10/'},
                            {text: 'v1.9', link: '/zh-cn/releases/v190/'},
                            {text: 'v1.8', link: '/zh-cn/releases/v180/'},
                            {text: 'v1.7', link: '/zh-cn/releases/v170/'},
                            {text: 'v1.6', link: '/zh-cn/releases/v160/'},
                            {text: 'v1.5.1', link: '/zh-cn/releases/v151/'},
                            {text: 'v1.5.0', link: '/zh-cn/releases/v150/'},
                            {text: 'v1.4.3', link: '/zh-cn/releases/v143/'},
                            {text: 'v1.4.2', link: '/zh-cn/releases/v142/'},
                            {text: 'v1.4.1', link: '/zh-cn/releases/v141/'},
                            {text: 'v1.4.0', link: '/zh-cn/releases/v140/'},
                            {text: 'v1.3.4', link: '/zh-cn/releases/v134/'},
                        ],
                    },
                ]
            },
            {text: 'GitHub', link: 'https://github.com/TuiQiao/CBoard'}
        ],
        lastUpdated: '上次更新时间',// 页面最下方的最后更新时间戳
        // navbar: false,
        sidebar: {
            '/zh-cn/intro/': getIntroSideBar('/zh-cn/intro'),
            '/zh-cn/manual/': getManualSidebar()
        },
        // sidebarDepth: 4,
        plugins: {
            '@vuepress/pwa': {
                serviceWorker: true,
                updatePopup: {
                    '/': {
                        message: 'New content is available.',
                        buttonText: 'Refresh'
                    },
                    '/zh-cn/': {
                        message: '发现新内容可用',
                        buttonText: '刷新'
                    }
                }
            },
        }
    },
});

function getIntroSideBar() {
    return [
        `preface`,
        `customer`,
    ]
}


function getManualSidebar(locale = 'zh-cn') {
    return [

        {
            title: '使用',   // 必要的
            path: `/${locale}/manual/3-foldersystem`,      // 可选的, 标题的跳转链接，应为绝对路径且必须存在
            icon: 'fas fa-book',
            collapsable: false, // 可选的, 默认值是 true,
            // sidebarDepth: 1,    // 可选的, 默认值是 1
            children: [
                `/${locale}/manual/3-foldersystem`,
                {
                    title: '数据源',
                    path: `/${locale}/manual/2-datasource`,
                },
                {
                    title: '数据导入',
                    sup: 'v1.11',
                    supClass: ['tip'],
                    path: `/${locale}/manual/datacenter/datacenter`,
                },
                {
                    title: '数据集',
                    children: [
                        `/${locale}/manual/4-dataset`,
                        `/${locale}/manual/dataset/2.1-jdbc-dataset`,
                        `/${locale}/manual/dataset/2.2-file-dataset`,
                        `/${locale}/manual/dataset/2.3-es-dataset`,
                        `/${locale}/manual/dataset/2.4-http-dataset`,
                    ]
                },
                {
                    title: '图表',   // 必要的
                    // path: `/${locale}/manual/widget/widget`,      // 可选的, 标题的跳转链接，应为绝对路径且必须存在
                    // collapsable: false, // 可选的, 默认值是 true,
                    sidebarDepth: 2,    // 可选的, 默认值是 1
                    children: [
                        `/${locale}/manual/widget/widget`,
                        `/${locale}/manual/widget/charts`,
                        `/${locale}/manual/widget/cross-table`,
                        {
                            sup: 'v1.5.1',
                            supClass: ['tip'],
                            path: `/${locale}/manual/widget/drill`,
                        },
                        `/${locale}/manual/widget/map`,
                        `/${locale}/manual/widget/areaMapUserData`,
                        `/${locale}/manual/widget/widget-js-hook`,
                    ]
                },
                {
                    title: '复杂报表',
                    sup: 'v1.5',
                    supClass: ['tip'],
                    sidebarDepth: 2,
                    children: [
                        `/${locale}/manual/report/1-intro`,
                        `/${locale}/manual/report/2-algorithm`,
                        `/${locale}/manual/report/3-dataset`,
                        `/${locale}/manual/report/4-expression`,
                        `/${locale}/manual/report/5-functions`,
                        `/${locale}/manual/report/6-rowtype`,
                        `/${locale}/manual/report/7-board-report`,
                        `/${locale}/manual/report/8-examples`,
                    ]
                },
                {
                    title: '看板',   // 必要的
                    // path: `/${locale}/manual/board/dashboard`,      // 可选的, 标题的跳转链接，应为绝对路径且必须存在
                    // collapsable: false, // 可选的, 默认值是 true,
                    // sidebarDepth: 4,    // 可选的, 默认值是 1
                    children: [
                        `/${locale}/manual/board/dashboard`,
                        `/${locale}/manual/board/dashboard-monitor`,
                        `/${locale}/manual/board/cockpit`,
                        {
                            sup: 'v1.14',
                            supClass: ['tip'],
                            path: `/${locale}/manual/board/_3d-model`,
                        },
                        `/${locale}/manual/board/`,
                        `/${locale}/manual/board/migrate`,
                        {
                            sup: 'v1.8',
                            supClass: ['tip'],
                            path: `/${locale}/manual/board/contrastive-analysis`,
                        },
                    ]
                },
                {
                    title: '数据门户',
                    sup: 'v1.12',
                    supClass: ['tip'],
                    sidebarDepth: 2,
                    children: [
                        `/${locale}/manual/portal/1-portal`,
                    ]
                },
                `/${locale}/manual/5-job`,
                `/${locale}/manual/6-shareResource`,
                `/${locale}/manual/7-userAdmin`,
                `/${locale}/manual/8-variable`,
                `/${locale}/manual/9-restful`,
                //{title: '安装与配置', path: '/manual/install'},
                //{title: '安装与配置', path: '/manual/install'},
            ]
        },
        {
            title: '运维',
            // path: `/${locale}/manual/1-install`,
            // collapsable: false,
            icon: 'fa fa-user-cog',
            children: [
                `/${locale}/manual/ops/1-install`,
                {
                    sup: 'v1.6.0',
                    supClass: ['tip'],
                    path: `/${locale}/manual/ops/1_2-install`
                },
                `/${locale}/manual/ops/3-update`,
                `/${locale}/manual/ops/tomcat2springboot`,
                `/${locale}/manual/advance/0-setting`,
                `/${locale}/manual/ops/2-puppetter`,
            ]
        },
        {
            title: '外部系统集成',   // 必要的
            path: `/${locale}/manual/integrate/1-iframe-dashboard`,      // 可选的, 标题的跳转链接，应为绝对路径且必须存在
            collapsable: false, // 可选的, 默认值是 true,
            icon: 'fa-sitemap',
            children: [
                `/${locale}/manual/integrate/1-iframe-dashboard`,
                `/${locale}/manual/integrate/2-passiveBoards`,
                {
                    sup: 'v1.9',
                    supClass: ['tip'],
                    path: `/${locale}/manual/integrate/3-components`,
                },
                `/${locale}/manual/integrate/5-module-integrate`,
            ]
        },
        {
            title: '常见问题',   // 必要的
            // path: `/${locale}/manual/3-foldersystem`,      // 可选的, 标题的跳转链接，应为绝对路径且必须存在
            icon: 'fa-question-circle',
            collapsable: true, // 可选的, 默认值是 true,
            // sidebarDepth: 3,    // 可选的, 默认值是 1
            children: [
                `/${locale}/manual/discuss/faq`,
                `/${locale}/manual/discuss/optimize`,
            ]
        },
    ]
}
